<% extend 'shared/admin-base' %>
<% block 'head': %>
<link rel="stylesheet" href="/dist/admin-user-assign.css">
<style>
    table img{
        width: 48px;
        height: 48px;
    }
    html .dropdown-menu {
        min-width: 80px;;
    }
    table td, table th{ text-align: center; vertical-align: middle !important;}
</style>

<% end %>
<div ng-controller="AppCtrl">
    <div ng-controller="ListCtrl">
        <div class="portlet box blue">
            <div class="portlet-title">
                <div class="caption"><i class="fa fa-reorder"></i>筛选条件</div>
                <div class="tools">
                    <a href="javascript:;" class="collapse"></a>
                </div>
            </div>
            <div class="portlet-body form">
                <!-- BEGIN FORM-->
                <div action="#" class="form-horizontal form-bordered">
                    <div class="form-body">
                        <div class="form-group">
                            <label class="control-label col-md-3">一级区域</label>
                            <div class="col-md-4">
                                <select multiple class="form-control" ng-model="areas">
                                    <% for item in @areas : %>
                                    <option value="<%= item.id %>"><%= item.title %></option>
                                    <% end %>
                                </select>
                                <span class="help-block">可多选</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-3">用户状态</label>
                            <div class="col-md-4">
                                <select class="form-control" ng-model="status">
                                    <option value="-1">待分配</option>
                                    <option value="0">待审核</option>
                                    <option value="1">已审核</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-md-3 control-label">姓名</label>
                            <div class="col-md-4">
                                <div class="input-group">
                                    <input type="text" class="form-control"  ng-model="name">
                                    <span class="input-group-addon"><i class="fa fa-user"></i></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-md-3 control-label">手机号</label>
                            <div class="col-md-4">
                                <div class="input-group">
                                    <input type="text" class="form-control"  ng-model="phone">
                                    <span class="input-group-addon"><i class="fa fa-phone"></i></span>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="control-label col-md-3">注册时间</label>
                            <div class="col-md-4">
                                <div class="input-group input-large date-picker input-daterange" data-date-format="mm/dd/yyyy">
                                    <input type="text" class="form-control" ng-model="startDate">
                                    <span class="input-group-addon">to</span>
                                    <input type="text" class="form-control" ng-model="endDate">
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="form-actions text-center ">
                        <button type="submit" class="btn blue" ng-click="search()" ng-disabled="loading">查询</button>
                        <button type="button" class="btn default" ng-click="reset()">清空</button>
                    </div>
                </div>
                <!-- END FORM-->
            </div>
        </div>
        <div class="alert alert-sm alert-info alert-dismissible ">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            勾选之后，翻页或者查询并不会清除勾选。也就是说在本页选择好条目后，扔可进入下一页进行选择，勾选不会自动清除。
        </div>
        <div style="margin: 8px 0;">
            <div class="btn-groups text-right">
                <div class="btn btn-default" ng-click="action()">分配业务员</div>
                <div class="btn btn-primary" ng-click="select('to be empty')">清空勾选</div>
            </div>
        </div>
        <table class="table  table-bordered table-hover">
            <thead>
            <tr>
                <th style="width: 48px;">
                    <input type="checkbox" ng-click="select('all')" ng-checked="all" id="all-checkbox">
                </th>
                <th>微信昵称</th>
                <th>姓名</th>
                <th>头像</th>
                <th>性别</th>
                <th>手机号</th>
                <th>一级区域</th>
                <th>二级区域</th>
                <th>地址</th>
                <th>业务员</th>
                <th>状态</th>
                <th>注册时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="user in list" ng-controller="UserCtrl">
                <td>
                    <input type="checkbox" ng-click="select(order.id)" ng-checked="order.selected">
                </td>
                <td>{{user.nickname}}</td>
                <td>{{user.name}}</td>
                <td><img ng-src="{{user.headimage}}" ></td>
                <td>{{user.sex}}</td>
                <td>{{user.phone}}</td>
                <td>{{user.DeliverAddresses[0].Area.TopArea.title}}</td>
                <td>{{user.DeliverAddresses[0].Area.title}}</td>
                <td>{{user.DeliverAddresses[0].province + user.DeliverAddresses[0].province + user.DeliverAddresses[0].city + user.DeliverAddresses[0].area + user.DeliverAddresses[0].address}}</td>
                <td>{{user.Adminer.nickname}}</td>
                <td>{{user.status | statusStr}}</td>
                <td>{{user.joinTime}}</td>
                <td>
                    <div class="btn-group">
                        <button class="btn btn-default btn-info btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
                            操作 <i class="fa fa-angle-down"></i>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li ng-click="action(user.id)"><a href="">分配业务员</a></li>
                        </ul>
                    </div>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="clearfix">
            <span class="pull-left">共<span>{{count}}</span>条数据 第<span>{{page}}/{{totalPage}}</span>页</span>
            <div class="btn-group pull-right" role="group" >
                <button type="button" class="btn btn-default" ng-click="page = page -1" ng-show="page != 1 ">上一页</button>
                <button type="button" class="btn btn-default" ng-click="page = page + 1" ng-show="page != totalPage && totalPage != 0">下一页</button>
            </div>
        </div>

        <div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h4 class="modal-title">分配业务员</h4>
                    </div>
                    <div class="modal-body">
                        <form class="form">
                            <div class="form-group">
                                <select ng-model="counterman" class="form-control">
                                    <% for item in @counterman : %>
                                    <option value="<%= item.id %>"><%= item.nickname %></option>
                                    <% end %>
                                </select>
                            </div>
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn blue" ng-click="submit()">提交</button>
                        <button type="button" class="btn default" data-dismiss="modal">取消</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
    </div>


</div>


<% block 'scripts': %>
<script src="/dist/admin-user-assign.js"></script>
<% end %>
